﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BlackBBS.Enums;
using BlackBBS.Models.Data;

namespace BlackBBS.Menus
{
    public class Main : MenuBase
    {
        public Main()
        {
        }

        public override void SendMenu()
        {
            this.Connection.SetCurrentArea(Area.Main);

            var handled = false;
            while (!handled)
            {
                this.Connection.ClearScreen();
                this.Connection.SendFile("MAIN.ANS");
                handled = this.HandleResponse(this.Connection.SendScript("MAIN.MNU"));
            }
        }

        public bool HandleResponse(Dictionary<string, string> response)
        {
            if (response == null || response.Count == 0)
            {
                return false;
            }

            var key = (response.First().Key ?? string.Empty).ToLower();
            var value = (response.First().Value ?? string.Empty).ToLower();

            switch (value)
            {
                case "a": // auto-message
                    break;

                case "b": // bbs list
                    var bbsList = new BlackBBS.Menus.BBSList
                    {
                        Connection = this.Connection
                    };
                    bbsList.Init();
                    bbsList.SendMenu();                    
                    break;

                case "c": // chat rooms
                    break;

                case "d": // doors           
                    var doors = new BlackBBS.Menus.ExtPrograms
                    {
                        Connection = this.Connection
                    };
                    doors.Init();
                    doors.SendMenu();                    
                    break;

                case "e": // email
                    break;

                case "f": // file areas
                    break;

                case "g": // good bye
                    base.DoLogOff(false);
                    return true;

                case "h": // call history
                    var callHistory = new BlackBBS.Menus.CallHistory
                    {
                        Connection = this.Connection
                    };
                    callHistory.Init();
                    callHistory.SendMenu();                    
                    break;

                case "i": // info (including hourly, daily and weekly usage stats)
                    break;

                case "m": // message areas
                    break;

                case "n": //note to sysop
                    break;

                case "p": // page sysop
                    break;

                case "s": // send feedback
                    break;

                case "t": // timebank
                    break;

                case "u": // user preferences 
                    break;

                case "$": // timebank
                    break;

                case "!": // whos online
                    break;

                case "?": // user help
                    break;

            }
            return false;
        }


    }
}
